{extend name="base/common"}

{block name="style"}

{/block}

{block name="page-header"}

{/block}

{block name="main"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="mail-box-header">
                <h2>文件上传下达 / 上级来文</h2>
                <div class="mail-tools tooltip-demo m-t-md">
                    <a href="{:Url('News/communicationadd')}" class="btn btn-primary btn-sm" ><i class="fa fa-plus"></i> 添加</a>
                    <form method="get" action="" class="pull-right mail-search">
                        <div class="input-group">
                            <input type="text" class="form-control input-sm" name="search" placeholder="搜索标题">
                            <div class="input-group-btn">
                                <button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-search"></i> 搜索</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div id="modal-form" class="modal fade" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-body">
                            <div class="form-horizontal from-add-user">
                                <h4 id="myTitle">查看文件流转</h4>
                                <ul class="domtree" id="domtree">
                                    <li>
                                        一级分发
                                        <ul id="one">
                                            <!--<li>1级菜单</li>-->
                                            <!--<li>1级菜单</li>-->
                                        </ul>
                                    </li>
                                    <li>
                                        二级分发
                                        <ul id="two">
                                            <!--<li>2级菜单</li>-->
                                            <!--<li>2级菜单</li>-->
                                        </ul>
                                    </li>
                                    <li>
                                        三级实施
                                        <ul id="three">
                                            <!--<li>3级菜单</li>-->
                                            <!--<li>3级菜单</li>-->
                                        </ul>
                                    </li>
                                </ul>

                                <div class="form-group">
                                    <div class="col-lg-offset-2 col-lg-10" style="text-align: right;">
                                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="mail-box">
                <table class="table table-hover table-mail">
                    <thead>
                    <tr>
                        <th></th>
                        <th>标题</th>
                        <th>类型</th>
                        <th>发布时间</th>
                        <th>流程流转</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>

                    <tbody>
                    {volist name="list" id="vo"}
                    <tr>
                        <td class="check-mail">
                            <input type="checkbox" class="i-checks ids" name="ids[]" value="{$vo.id}">
                        </td>
                        <td>{$vo.title|msubstr=0,20}</td>
                        <td>{$vo.type_text}</td>
                        <td>{$vo.create_time|time_format='Y-m-d H:i'}</td>
                        <td><a href="javascript:void(0);" onclick="viewProgress('{$vo.id}')" class="confirm btn-sm btn-primary">查看流转</a></td>
                        <td>{$vo.status_text}</td>
                        <td>
                            <a href="{:Url('News/communicationedit?id='.$vo['id'])}" class="confirm btn-sm btn-primary"><i class="fa fa-pencil"></i> 修改</a>
                            <a href="{:Url('News/communicationdel?id='.$vo['id'])}" class="confirm btn-sm btn-danger ajax-del"><i class="fa fa-trash-o"></i> 删除</a>
                        </td>
                    </tr>
                    {/volist}
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="10">
                            <div class="page">{$list->render()}</div>
                        </td>
                    </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script src="/admin/js/plugins/iCheck/icheck.min.js"></script>
<script>
    highlight_subnav("{:Url('News/communication')}");

    $(document).ready(function(){
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
        $(".check-all").on("ifChanged",function(){
            $("tbody").find(".ids").iCheck("toggle");
        });
    });

    //查看文件流转
    function viewProgress(id) {
        //默认清除li标签
        $("#one").find("li").remove();
        $("#two").find("li").remove();
        $("#three").find("li").remove();
        //方法获取后新增li
        $.ajax({
            type:'post',
            url: "/admin/news/getCommunicationList",
            data:{
                id: id
            },
            success: function (data) {
                var html;
                var msg = data.data;
                $.each(msg,function(index,value){
                    html = '<li><span>姓名：'+value.username+'</span>&nbsp;&nbsp;<span>备注：'+value.remarks+'</span>&nbsp;&nbsp;' +
                        '<span>状态:<font>'+value.status_text+'</font></span></li>';
                    if(value.permission == 1) {
                        $('#one').append(html);
                    }
                    if(value.permission == 2) {
                        $('#two').append(html);
                    }
                    if(value.permission == 3) {
                        $('#three').append(html);
                    }
                });
                $('#modal-form').modal('show');
            }
        });
    }
</script>
{/block}